﻿using UnityEngine;

namespace UniBrickClient.Utils
{
    public class ConversionUtils
    {
        public static string VectorToString(Vector3 vector)
        {
            return vector.x + "," + vector.y + "," + vector.z;
        }

        public static Vector3 VectorFromString(string vectorString)
        {
            var coords = vectorString.Split(',');
            var x = float.Parse(coords[0]);
            var y = float.Parse(coords[1]);
            var z = float.Parse(coords[2]);
            return new Vector3(x, y, z);
        }

        public static string QuaternionToString(Quaternion quaternion)
        {
            return quaternion.x + "," + quaternion.y + "," + quaternion.z + "," + quaternion.w;
        }

        public static Quaternion QuaternionFromString(string quaternionString)
        {
            var coords = quaternionString.Split(',');
            var x = float.Parse(coords[0]);
            var y = float.Parse(coords[1]);
            var z = float.Parse(coords[2]);
            var w = float.Parse(coords[2]);
            return new Quaternion(x, y, z, w);
        }
    }
}